package ch.sfug.player{

	

	import ch.sfug.player.IPlaylist;
	import ch.sfug.player.ITrack;





	public class Playlist implements IPlaylist {
		//{ ATTRIBUTES
		
		private var _title:String;
		private var _numTrack:int;

		
		protected var _tracks:Array;

		//}

		//{ GETTER-SETTER
		

		public function get title():String{ return this._title; }
 		/** @private */
		public function set title(newValue:String):void{
			this._title = newValue;
		}
		/**
		* number of tracks in playlist
		*/
		public function get numTrack():int { return this._tracks.length; }
		//}


		//{ INIT
		public function Playlist() {
			_tracks = new Array();
		}

		//}

		//{ METHODS
		
		
		/**
		* get a track at position
		* @return	track or null
		* @param	pos	position in playlist
		*/
		public function getTrack(pos:int):ITrack{
			return _tracks[pos];
		}
		/**
		* adds a track to the playlist
		* @param	trk	to add track
		*/
		public function addTrack(trk:ITrack):void{
			_tracks.push(trk);
		}
		/**
		* removes a track from the playlist
		* @param	trk	track
		*/
		public function removeTrack(trk:ITrack):void{
			_tracks.splice(_tracks.indexOf(trk), 1);
		}
		/**
		* clears the playlist
		*/
		public function clear():void{
			_tracks = [];
		}
		/**
		* gets a specific info about the playlist
		* @return	info
		* @param	id	info id
		*/
		public function getPlaylistInfo(id:String):Object{
			return this[id];
		}
		/**
		* sets a specific playlist info
		* @param	id	info id
		* @param	obj	info object
		*/
		public function setPlaylistInfo(id:String,obj:Object):void{
			this[id] = obj;
		}
		//}

		//{ PRIVATE METHODS
		//}



	}

}

